<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.10"/>
<title>sock: E:/git/sock/sock/net/tcp_connection.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">sock
   &#160;<span id="projectnumber">v0.11</span>
   </div>
   <div id="projectbrief">C++ Network Library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.10 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_885cc87fac2d91e269af0a5a959fa5f6.html">E:</a></li><li class="navelem"><a class="el" href="dir_4e091ed8704426a7a4980368ba259fde.html">git</a></li><li class="navelem"><a class="el" href="dir_99ede9081e3122cb31ab1bd7b142cd6c.html">sock</a></li><li class="navelem"><a class="el" href="dir_7c33e989e8c050d7b2ba91a16c41033d.html">sock</a></li><li class="navelem"><a class="el" href="dir_d903d5916af6fe48bd2085e947d1c878.html">net</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">tcp_connection.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="tcp__connection_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">/******************************************************************************</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment"> * Name         : tcp_connection.h</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment"> * Author       : 671643387</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment"> * Date         : 2015年10月6日</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment"> * Description  :</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment"> *****************************************************************************/</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;</div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="preprocessor">#ifndef SOCK_NET_TCP_CONNECTION_H_</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="preprocessor">#define SOCK_NET_TCP_CONNECTION_H_</span></div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;</div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="preprocessor">#include &lt;boost/function.hpp&gt;</span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="preprocessor">#include &lt;<a class="code" href="net__event__handler_8h.html">sock/net/net_event_handler.h</a>&gt;</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="preprocessor">#include &lt;<a class="code" href="socket_8h.html">sock/net/socket.h</a>&gt;</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="preprocessor">#include &lt;<a class="code" href="tcp__connection__input__stream_8h.html">sock/net/tcp_connection_input_stream.h</a>&gt;</span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="preprocessor">#include &lt;<a class="code" href="tcp__connection__output__stream_8h.html">sock/net/tcp_connection_output_stream.h</a>&gt;</span></div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;</div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespacesock.html">sock</a></div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;{</div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;    <span class="keyword">namespace </span>net</div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;    {</div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;        <span class="keyword">class </span>TcpServer;</div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;        <span class="keyword">class </span>TcpWorker;</div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;</div>
<div class="line"><a name="l00027"></a><span class="lineno"><a class="line" href="classsock_1_1net_1_1_tcp_connection.html">   27</a></span>&#160;        <span class="keyword">class </span><a class="code" href="classsock_1_1net_1_1_tcp_connection.html">TcpConnection</a> : <span class="keyword">public</span> <a class="code" href="classsock_1_1net_1_1_net_event_handler.html">NetEventHandler</a></div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;        {</div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;        <span class="keyword">public</span>:</div>
<div class="line"><a name="l00030"></a><span class="lineno"><a class="line" href="classsock_1_1net_1_1_tcp_connection.html#a9d9ea93c3a51141616167ae78c0238ec">   30</a></span>&#160;            <span class="keyword">typedef</span> boost::function&lt;void(TcpConnection&amp;)&gt; <a class="code" href="classsock_1_1net_1_1_tcp_connection.html#a9d9ea93c3a51141616167ae78c0238ec">PassTcpConnectionRefFunc</a>;</div>
<div class="line"><a name="l00031"></a><span class="lineno"><a class="line" href="classsock_1_1net_1_1_tcp_connection.html#a836ed49de731537f208e17d07868a9d8">   31</a></span>&#160;            <span class="keyword">typedef</span> boost::function&lt;void(TcpConnection&amp;, TcpConnectionInputStream&amp;)&gt; <a class="code" href="classsock_1_1net_1_1_tcp_connection.html#a836ed49de731537f208e17d07868a9d8">TcpConnectionReadFunc</a>;</div>
<div class="line"><a name="l00032"></a><span class="lineno"><a class="line" href="classsock_1_1net_1_1_tcp_connection.html#ab8951d995ac681b06a8d8dfdadd219aa">   32</a></span>&#160;            <span class="keyword">typedef</span> boost::function&lt;void(TcpConnection&amp;, TcpConnectionOutputStream&amp;)&gt; <a class="code" href="classsock_1_1net_1_1_tcp_connection.html#ab8951d995ac681b06a8d8dfdadd219aa">TcpConnectionWriteFunc</a>;</div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;</div>
<div class="line"><a name="l00034"></a><span class="lineno"><a class="line" href="classsock_1_1net_1_1_tcp_connection.html#ac6a1f1dc74ce847b7aab5f9c1c8d6574">   34</a></span>&#160;            <span class="keyword">enum</span> <a class="code" href="classsock_1_1net_1_1_tcp_connection.html#ac6a1f1dc74ce847b7aab5f9c1c8d6574">State</a></div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;            {</div>
<div class="line"><a name="l00036"></a><span class="lineno"><a class="line" href="classsock_1_1net_1_1_tcp_connection.html#ac6a1f1dc74ce847b7aab5f9c1c8d6574a92fcb3956c72ee14fb17b6d187517d9a">   36</a></span>&#160;                <a class="code" href="classsock_1_1net_1_1_tcp_connection.html#ac6a1f1dc74ce847b7aab5f9c1c8d6574a92fcb3956c72ee14fb17b6d187517d9a">CONNECT</a>,</div>
<div class="line"><a name="l00037"></a><span class="lineno"><a class="line" href="classsock_1_1net_1_1_tcp_connection.html#ac6a1f1dc74ce847b7aab5f9c1c8d6574a7deeba93cda3dfa27db748cafe5ca9aa">   37</a></span>&#160;                <a class="code" href="classsock_1_1net_1_1_tcp_connection.html#ac6a1f1dc74ce847b7aab5f9c1c8d6574a7deeba93cda3dfa27db748cafe5ca9aa">CLOSING</a>,</div>
<div class="line"><a name="l00038"></a><span class="lineno"><a class="line" href="classsock_1_1net_1_1_tcp_connection.html#ac6a1f1dc74ce847b7aab5f9c1c8d6574a456b48c073c8b92394f8e74a39646ec4">   38</a></span>&#160;                <a class="code" href="classsock_1_1net_1_1_tcp_connection.html#ac6a1f1dc74ce847b7aab5f9c1c8d6574a456b48c073c8b92394f8e74a39646ec4">CLOSED</a></div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;            };</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;        <span class="keyword">public</span>:</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;            <a class="code" href="classsock_1_1net_1_1_tcp_connection.html#a43ee94855cd5bc5b46e5bb5b3fbb545c">TcpConnection</a>(sock_t <a class="code" href="namespacesock.html">sock</a>, <span class="keywordtype">size_t</span> isSize = 1024 * 32, <span class="keywordtype">size_t</span> osSize = 1024 * 32);</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;            <a class="code" href="classsock_1_1net_1_1_tcp_connection.html#a43ee94855cd5bc5b46e5bb5b3fbb545c">TcpConnection</a>(sock_t <a class="code" href="namespacesock.html">sock</a>, <a class="code" href="namespacesock_1_1net.html#a2165d5b91136adc8c72ad25bfdbd0968">ByteBuffer</a> ibuff, <a class="code" href="namespacesock_1_1net.html#a2165d5b91136adc8c72ad25bfdbd0968">ByteBuffer</a> obuff, <span class="keywordtype">size_t</span> isSize, <span class="keywordtype">size_t</span> osSize);</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;            <span class="keyword">virtual</span> <a class="code" href="classsock_1_1net_1_1_tcp_connection.html#a726cd8559fa3a133b47a15f10ebbe6dc">~TcpConnection</a>(<span class="keywordtype">void</span>);</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;        <span class="keyword">public</span>:</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;            <span class="keywordtype">void</span> <a class="code" href="classsock_1_1net_1_1_tcp_connection.html#a61f65d30aed34c170e355ce5841dc1d3">shutdown</a>(<span class="keywordtype">void</span>);</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;</div>
<div class="line"><a name="l00070"></a><span class="lineno"><a class="line" href="classsock_1_1net_1_1_tcp_connection.html#a180476e4513ce0ccdc23316ce791faf2">   70</a></span>&#160;            <span class="keywordtype">int</span> <a class="code" href="classsock_1_1net_1_1_tcp_connection.html#a180476e4513ce0ccdc23316ce791faf2">getId</a>(<span class="keywordtype">void</span>)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> id_; }</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;</div>
<div class="line"><a name="l00076"></a><span class="lineno"><a class="line" href="classsock_1_1net_1_1_tcp_connection.html#a895047bafd0cbed7850da3fd355c679c">   76</a></span>&#160;            <a class="code" href="classsock_1_1net_1_1_socket.html">Socket</a>* <a class="code" href="classsock_1_1net_1_1_tcp_connection.html#a895047bafd0cbed7850da3fd355c679c">getSock</a>(<span class="keywordtype">void</span>) { <span class="keywordflow">return</span> &amp;sock_; }</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;</div>
<div class="line"><a name="l00082"></a><span class="lineno"><a class="line" href="classsock_1_1net_1_1_tcp_connection.html#a60311ccc61cbe63853b5c07027c807e3">   82</a></span>&#160;            <a class="code" href="classsock_1_1net_1_1_tcp_connection_input_stream.html">TcpConnectionInputStream</a>&amp; <a class="code" href="classsock_1_1net_1_1_tcp_connection.html#a60311ccc61cbe63853b5c07027c807e3">getInputStream</a>(<span class="keywordtype">void</span>) { <span class="keywordflow">return</span> inputStream_; }</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;</div>
<div class="line"><a name="l00088"></a><span class="lineno"><a class="line" href="classsock_1_1net_1_1_tcp_connection.html#ac8b5476c831b445845d6769e0adf0390">   88</a></span>&#160;            <a class="code" href="classsock_1_1net_1_1_tcp_connection_output_stream.html">TcpConnectionOutputStream</a>&amp; <a class="code" href="classsock_1_1net_1_1_tcp_connection.html#ac8b5476c831b445845d6769e0adf0390">getOutputStream</a>(<span class="keywordtype">void</span>) { <span class="keywordflow">return</span> outputStream_; }</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;</div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;        <span class="keyword">public</span>:</div>
<div class="line"><a name="l00095"></a><span class="lineno"><a class="line" href="classsock_1_1net_1_1_tcp_connection.html#a47110635b794afc5a26640984bf3bc97">   95</a></span>&#160;            <span class="keywordtype">void</span> <a class="code" href="classsock_1_1net_1_1_tcp_connection.html#a47110635b794afc5a26640984bf3bc97">setReadFN</a>(TcpConnectionReadFunc fn)</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;            { readFn_ = fn; }</div>
<div class="line"><a name="l00101"></a><span class="lineno"><a class="line" href="classsock_1_1net_1_1_tcp_connection.html#a42f560457d86273fe85150a879fe4b50">  101</a></span>&#160;            <span class="keywordtype">void</span> <a class="code" href="classsock_1_1net_1_1_tcp_connection.html#a42f560457d86273fe85150a879fe4b50">setWriteFN</a>(TcpConnectionWriteFunc fn)</div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;            { writeFn_ = fn; }</div>
<div class="line"><a name="l00107"></a><span class="lineno"><a class="line" href="classsock_1_1net_1_1_tcp_connection.html#a1007848144d161705c5316ab51e17b36">  107</a></span>&#160;            <span class="keywordtype">void</span> <a class="code" href="classsock_1_1net_1_1_tcp_connection.html#a1007848144d161705c5316ab51e17b36">setErrorFN</a>(PassTcpConnectionRefFunc fn)</div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;            { errorFn_ = fn; }</div>
<div class="line"><a name="l00113"></a><span class="lineno"><a class="line" href="classsock_1_1net_1_1_tcp_connection.html#a7588b091cb1d02fd91c2fd0a81197393">  113</a></span>&#160;            <span class="keywordtype">void</span> <a class="code" href="classsock_1_1net_1_1_tcp_connection.html#a7588b091cb1d02fd91c2fd0a81197393">setCloseFN</a>(PassTcpConnectionRefFunc fn)</div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;            { closeFn_ = fn; }</div>
<div class="line"><a name="l00119"></a><span class="lineno"><a class="line" href="classsock_1_1net_1_1_tcp_connection.html#a634053043ee4491da121ba3ba78a7a2f">  119</a></span>&#160;            <span class="keywordtype">void</span> <a class="code" href="classsock_1_1net_1_1_tcp_connection.html#a634053043ee4491da121ba3ba78a7a2f">setHeartbeatFN</a>(PassTcpConnectionRefFunc fn)</div>
<div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;            { heartbeatFn_ = fn; }</div>
<div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;</div>
<div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;        <span class="keyword">public</span>:</div>
<div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;            <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classsock_1_1net_1_1_tcp_connection.html#a7169d0396d8b3f9d3bc0bfa651c39f40">handleInput</a>(<span class="keywordtype">void</span>);     <span class="comment">/* @override */</span></div>
<div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;            <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classsock_1_1net_1_1_tcp_connection.html#ada4e4dc8bcdb148eef20a2b479697bbf">handleOutput</a>(<span class="keywordtype">void</span>);     <span class="comment">/* @override */</span></div>
<div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;            <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classsock_1_1net_1_1_tcp_connection.html#ab177cdd1021f1452a8b49c0238ab5186">handleError</a>(<span class="keywordtype">void</span>);     <span class="comment">/* @override */</span></div>
<div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;            <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classsock_1_1net_1_1_tcp_connection.html#ad5d67c0a60a1f2c9816e550e4f110e21">handleClose</a>(<span class="keywordtype">void</span>);     <span class="comment">/* @override */</span></div>
<div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;            <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classsock_1_1net_1_1_tcp_connection.html#a4da2739b37a3ded075a8f44a8e6ef519">handleHeartbeat</a>(<span class="keywordtype">void</span>); <span class="comment">/* @override */</span></div>
<div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;</div>
<div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;        <span class="keyword">private</span>:</div>
<div class="line"><a name="l00130"></a><span class="lineno"><a class="line" href="classsock_1_1net_1_1_tcp_connection.html#a3ecf3132e8c4bf890c07853cfab7619c">  130</a></span>&#160;            <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classsock_1_1net_1_1_tcp_server.html">TcpServer</a>;</div>
<div class="line"><a name="l00131"></a><span class="lineno"><a class="line" href="classsock_1_1net_1_1_tcp_connection.html#a0736aba6eec2f2c2a13494228473b67c">  131</a></span>&#160;            <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classsock_1_1net_1_1_tcp_worker.html">TcpWorker</a>;</div>
<div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;            <span class="keywordtype">void</span> setId(<span class="keywordtype">int</span> <span class="keywordtype">id</span>) { id_ = id; }</div>
<div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;            <span class="keywordtype">void</span> setServer(<a class="code" href="classsock_1_1net_1_1_tcp_server.html">TcpServer</a>* server) { server_ = server; }</div>
<div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;            <span class="keywordtype">void</span> setWorker(<a class="code" href="classsock_1_1net_1_1_tcp_connection.html#a0736aba6eec2f2c2a13494228473b67c">TcpWorker</a>* worker) { worker_ = worker; }</div>
<div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;            <span class="keywordtype">void</span> <a class="code" href="thread_8cc.html#af4e3cd37f8df7dbde1c46d01772b84e5">setState</a>(<a class="code" href="classsock_1_1net_1_1_tcp_connection.html#ac6a1f1dc74ce847b7aab5f9c1c8d6574">State</a> state) { state_ = state; }</div>
<div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;</div>
<div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;        <span class="keyword">private</span>:</div>
<div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;            <span class="keywordtype">void</span> doError(<span class="keywordtype">void</span>);</div>
<div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;</div>
<div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;        <span class="keyword">private</span>:</div>
<div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;            <span class="keywordtype">int</span> id_;                                            <span class="comment">/* 连接ID */</span></div>
<div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;            <a class="code" href="classsock_1_1net_1_1_tcp_connection.html#ac6a1f1dc74ce847b7aab5f9c1c8d6574">State</a> state_;                                       <span class="comment">/* 状态 */</span></div>
<div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;            <a class="code" href="classsock_1_1net_1_1_tcp_connection.html#a3ecf3132e8c4bf890c07853cfab7619c">TcpServer</a>* server_;                                 <span class="comment">/* TCP服务器 */</span></div>
<div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;            <a class="code" href="classsock_1_1net_1_1_tcp_connection.html#a0736aba6eec2f2c2a13494228473b67c">TcpWorker</a>* worker_;                                 <span class="comment">/* TCP线程 */</span></div>
<div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;</div>
<div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;            Socket sock_;                                       <span class="comment">/* 管理的套接字 */</span></div>
<div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;</div>
<div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;            TcpConnectionInputStream inputStream_;              <span class="comment">/* 输入流 */</span></div>
<div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;            TcpConnectionOutputStream outputStream_;            <span class="comment">/* 输出流 */</span></div>
<div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;</div>
<div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;            TcpConnectionReadFunc readFn_;                      <span class="comment">/* 读回调 */</span></div>
<div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;            TcpConnectionWriteFunc writeFn_;                    <span class="comment">/* 写回调 */</span></div>
<div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;            PassTcpConnectionRefFunc errorFn_;                  <span class="comment">/* 错误回调 */</span></div>
<div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;            PassTcpConnectionRefFunc closeFn_;                  <span class="comment">/* 关闭回调 */</span></div>
<div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;            PassTcpConnectionRefFunc heartbeatFn_;              <span class="comment">/* 心跳回调 */</span></div>
<div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;        };</div>
<div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;</div>
<div class="line"><a name="l00158"></a><span class="lineno"><a class="line" href="namespacesock_1_1net.html#ac7ab8c7fe4e8e023f2fea799b74122ed">  158</a></span>&#160;        <span class="keyword">typedef</span> boost::shared_ptr&lt;TcpConnection&gt; <a class="code" href="namespacesock_1_1net.html#ac7ab8c7fe4e8e023f2fea799b74122ed">TcpConnectionPtr</a>;</div>
<div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;    }</div>
<div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;}</div>
<div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;</div>
<div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;<span class="preprocessor">#endif </span><span class="comment">/* SOCK_NET_TCP_CONNECTION_H_ */</span><span class="preprocessor"></span></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_connection_html_a42f560457d86273fe85150a879fe4b50"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_connection.html#a42f560457d86273fe85150a879fe4b50">sock::net::TcpConnection::setWriteFN</a></div><div class="ttdeci">void setWriteFN(TcpConnectionWriteFunc fn)</div><div class="ttdoc">设置写回调 </div><div class="ttdef"><b>Definition:</b> tcp_connection.h:101</div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_connection_html_a43ee94855cd5bc5b46e5bb5b3fbb545c"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_connection.html#a43ee94855cd5bc5b46e5bb5b3fbb545c">sock::net::TcpConnection::TcpConnection</a></div><div class="ttdeci">TcpConnection(sock_t sock, size_t isSize=1024 *32, size_t osSize=1024 *32)</div><div class="ttdoc">Tcp连接构造函数 </div><div class="ttdef"><b>Definition:</b> tcp_connection.cc:13</div></div>
<div class="ttc" id="namespacesock_1_1net_html_a2165d5b91136adc8c72ad25bfdbd0968"><div class="ttname"><a href="namespacesock_1_1net.html#a2165d5b91136adc8c72ad25bfdbd0968">sock::net::ByteBuffer</a></div><div class="ttdeci">boost::shared_array&lt; char &gt; ByteBuffer</div><div class="ttdef"><b>Definition:</b> tcp_connection_stream.h:28</div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_connection_html_ac6a1f1dc74ce847b7aab5f9c1c8d6574a456b48c073c8b92394f8e74a39646ec4"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_connection.html#ac6a1f1dc74ce847b7aab5f9c1c8d6574a456b48c073c8b92394f8e74a39646ec4">sock::net::TcpConnection::CLOSED</a></div><div class="ttdef"><b>Definition:</b> tcp_connection.h:38</div></div>
<div class="ttc" id="classsock_1_1net_1_1_net_event_handler_html"><div class="ttname"><a href="classsock_1_1net_1_1_net_event_handler.html">sock::net::NetEventHandler</a></div><div class="ttdoc">网络事件处理器 </div><div class="ttdef"><b>Definition:</b> net_event_handler.h:20</div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_connection_html_a1007848144d161705c5316ab51e17b36"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_connection.html#a1007848144d161705c5316ab51e17b36">sock::net::TcpConnection::setErrorFN</a></div><div class="ttdeci">void setErrorFN(PassTcpConnectionRefFunc fn)</div><div class="ttdoc">设置错误回调 </div><div class="ttdef"><b>Definition:</b> tcp_connection.h:107</div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_connection_html_ad5d67c0a60a1f2c9816e550e4f110e21"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_connection.html#ad5d67c0a60a1f2c9816e550e4f110e21">sock::net::TcpConnection::handleClose</a></div><div class="ttdeci">virtual void handleClose(void)</div><div class="ttdoc">处理关闭 </div><div class="ttdef"><b>Definition:</b> tcp_connection.cc:128</div></div>
<div class="ttc" id="thread_8cc_html_af4e3cd37f8df7dbde1c46d01772b84e5"><div class="ttname"><a href="thread_8cc.html#af4e3cd37f8df7dbde1c46d01772b84e5">setState</a></div><div class="ttdeci">thread setState(Thread::RUNNING)</div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_connection_html_a60311ccc61cbe63853b5c07027c807e3"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_connection.html#a60311ccc61cbe63853b5c07027c807e3">sock::net::TcpConnection::getInputStream</a></div><div class="ttdeci">TcpConnectionInputStream &amp; getInputStream(void)</div><div class="ttdoc">获取输入流 </div><div class="ttdef"><b>Definition:</b> tcp_connection.h:82</div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_connection_html_ab8951d995ac681b06a8d8dfdadd219aa"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_connection.html#ab8951d995ac681b06a8d8dfdadd219aa">sock::net::TcpConnection::TcpConnectionWriteFunc</a></div><div class="ttdeci">boost::function&lt; void(TcpConnection &amp;, TcpConnectionOutputStream &amp;)&gt; TcpConnectionWriteFunc</div><div class="ttdef"><b>Definition:</b> tcp_connection.h:32</div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_connection_html_ac6a1f1dc74ce847b7aab5f9c1c8d6574a92fcb3956c72ee14fb17b6d187517d9a"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_connection.html#ac6a1f1dc74ce847b7aab5f9c1c8d6574a92fcb3956c72ee14fb17b6d187517d9a">sock::net::TcpConnection::CONNECT</a></div><div class="ttdef"><b>Definition:</b> tcp_connection.h:36</div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_connection_html_a0736aba6eec2f2c2a13494228473b67c"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_connection.html#a0736aba6eec2f2c2a13494228473b67c">sock::net::TcpConnection::TcpWorker</a></div><div class="ttdeci">friend class TcpWorker</div><div class="ttdef"><b>Definition:</b> tcp_connection.h:131</div></div>
<div class="ttc" id="namespacesock_1_1net_html_ac7ab8c7fe4e8e023f2fea799b74122ed"><div class="ttname"><a href="namespacesock_1_1net.html#ac7ab8c7fe4e8e023f2fea799b74122ed">sock::net::TcpConnectionPtr</a></div><div class="ttdeci">boost::shared_ptr&lt; TcpConnection &gt; TcpConnectionPtr</div><div class="ttdef"><b>Definition:</b> tcp_connection.h:158</div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_connection_html_a47110635b794afc5a26640984bf3bc97"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_connection.html#a47110635b794afc5a26640984bf3bc97">sock::net::TcpConnection::setReadFN</a></div><div class="ttdeci">void setReadFN(TcpConnectionReadFunc fn)</div><div class="ttdoc">设置读回调 </div><div class="ttdef"><b>Definition:</b> tcp_connection.h:95</div></div>
<div class="ttc" id="tcp__connection__output__stream_8h_html"><div class="ttname"><a href="tcp__connection__output__stream_8h.html">tcp_connection_output_stream.h</a></div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_worker_html"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_worker.html">sock::net::TcpWorker</a></div><div class="ttdef"><b>Definition:</b> tcp_worker.h:25</div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_connection_html"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_connection.html">sock::net::TcpConnection</a></div><div class="ttdoc">网络连接 </div><div class="ttdef"><b>Definition:</b> tcp_connection.h:27</div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_connection_html_a634053043ee4491da121ba3ba78a7a2f"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_connection.html#a634053043ee4491da121ba3ba78a7a2f">sock::net::TcpConnection::setHeartbeatFN</a></div><div class="ttdeci">void setHeartbeatFN(PassTcpConnectionRefFunc fn)</div><div class="ttdoc">设置心跳回调 </div><div class="ttdef"><b>Definition:</b> tcp_connection.h:119</div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_connection_html_ada4e4dc8bcdb148eef20a2b479697bbf"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_connection.html#ada4e4dc8bcdb148eef20a2b479697bbf">sock::net::TcpConnection::handleOutput</a></div><div class="ttdeci">virtual void handleOutput(void)</div><div class="ttdoc">处理网络输出 </div><div class="ttdef"><b>Definition:</b> tcp_connection.cc:92</div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_connection_html_a836ed49de731537f208e17d07868a9d8"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_connection.html#a836ed49de731537f208e17d07868a9d8">sock::net::TcpConnection::TcpConnectionReadFunc</a></div><div class="ttdeci">boost::function&lt; void(TcpConnection &amp;, TcpConnectionInputStream &amp;)&gt; TcpConnectionReadFunc</div><div class="ttdef"><b>Definition:</b> tcp_connection.h:31</div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_connection_html_ac6a1f1dc74ce847b7aab5f9c1c8d6574a7deeba93cda3dfa27db748cafe5ca9aa"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_connection.html#ac6a1f1dc74ce847b7aab5f9c1c8d6574a7deeba93cda3dfa27db748cafe5ca9aa">sock::net::TcpConnection::CLOSING</a></div><div class="ttdef"><b>Definition:</b> tcp_connection.h:37</div></div>
<div class="ttc" id="namespacesock_html"><div class="ttname"><a href="namespacesock.html">sock</a></div><div class="ttdef"><b>Definition:</b> atomic.h:17</div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_connection_output_stream_html"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_connection_output_stream.html">sock::net::TcpConnectionOutputStream</a></div><div class="ttdoc">Tcp连接输出流 </div><div class="ttdef"><b>Definition:</b> tcp_connection_output_stream.h:20</div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_connection_html_ac8b5476c831b445845d6769e0adf0390"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_connection.html#ac8b5476c831b445845d6769e0adf0390">sock::net::TcpConnection::getOutputStream</a></div><div class="ttdeci">TcpConnectionOutputStream &amp; getOutputStream(void)</div><div class="ttdoc">获取输出流 </div><div class="ttdef"><b>Definition:</b> tcp_connection.h:88</div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_connection_html_a726cd8559fa3a133b47a15f10ebbe6dc"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_connection.html#a726cd8559fa3a133b47a15f10ebbe6dc">sock::net::TcpConnection::~TcpConnection</a></div><div class="ttdeci">virtual ~TcpConnection(void)</div><div class="ttdef"><b>Definition:</b> tcp_connection.cc:47</div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_server_html"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_server.html">sock::net::TcpServer</a></div><div class="ttdef"><b>Definition:</b> tcp_server.h:29</div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_connection_html_a3ecf3132e8c4bf890c07853cfab7619c"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_connection.html#a3ecf3132e8c4bf890c07853cfab7619c">sock::net::TcpConnection::TcpServer</a></div><div class="ttdeci">friend class TcpServer</div><div class="ttdef"><b>Definition:</b> tcp_connection.h:130</div></div>
<div class="ttc" id="tcp__connection__input__stream_8h_html"><div class="ttname"><a href="tcp__connection__input__stream_8h.html">tcp_connection_input_stream.h</a></div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_connection_html_a7169d0396d8b3f9d3bc0bfa651c39f40"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_connection.html#a7169d0396d8b3f9d3bc0bfa651c39f40">sock::net::TcpConnection::handleInput</a></div><div class="ttdeci">virtual void handleInput(void)</div><div class="ttdoc">处理网络输入 </div><div class="ttdef"><b>Definition:</b> tcp_connection.cc:74</div></div>
<div class="ttc" id="net__event__handler_8h_html"><div class="ttname"><a href="net__event__handler_8h.html">net_event_handler.h</a></div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_connection_html_a7588b091cb1d02fd91c2fd0a81197393"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_connection.html#a7588b091cb1d02fd91c2fd0a81197393">sock::net::TcpConnection::setCloseFN</a></div><div class="ttdeci">void setCloseFN(PassTcpConnectionRefFunc fn)</div><div class="ttdoc">设置关闭回调 </div><div class="ttdef"><b>Definition:</b> tcp_connection.h:113</div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_connection_html_a61f65d30aed34c170e355ce5841dc1d3"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_connection.html#a61f65d30aed34c170e355ce5841dc1d3">sock::net::TcpConnection::shutdown</a></div><div class="ttdeci">void shutdown(void)</div><div class="ttdoc">关闭连接 </div><div class="ttdef"><b>Definition:</b> tcp_connection.cc:52</div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_connection_html_a4da2739b37a3ded075a8f44a8e6ef519"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_connection.html#a4da2739b37a3ded075a8f44a8e6ef519">sock::net::TcpConnection::handleHeartbeat</a></div><div class="ttdeci">virtual void handleHeartbeat(void)</div><div class="ttdoc">处理心跳 </div><div class="ttdef"><b>Definition:</b> tcp_connection.cc:118</div></div>
<div class="ttc" id="classsock_1_1net_1_1_socket_html"><div class="ttname"><a href="classsock_1_1net_1_1_socket.html">sock::net::Socket</a></div><div class="ttdoc">套接字 </div><div class="ttdef"><b>Definition:</b> socket.h:38</div></div>
<div class="ttc" id="socket_8h_html"><div class="ttname"><a href="socket_8h.html">socket.h</a></div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_connection_input_stream_html"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_connection_input_stream.html">sock::net::TcpConnectionInputStream</a></div><div class="ttdoc">Tcp连接输入流 </div><div class="ttdef"><b>Definition:</b> tcp_connection_input_stream.h:20</div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_connection_html_ab177cdd1021f1452a8b49c0238ab5186"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_connection.html#ab177cdd1021f1452a8b49c0238ab5186">sock::net::TcpConnection::handleError</a></div><div class="ttdeci">virtual void handleError(void)</div><div class="ttdoc">处理网络错误 </div><div class="ttdef"><b>Definition:</b> tcp_connection.cc:110</div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_connection_html_a895047bafd0cbed7850da3fd355c679c"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_connection.html#a895047bafd0cbed7850da3fd355c679c">sock::net::TcpConnection::getSock</a></div><div class="ttdeci">Socket * getSock(void)</div><div class="ttdoc">获取套接字 </div><div class="ttdef"><b>Definition:</b> tcp_connection.h:76</div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_connection_html_a180476e4513ce0ccdc23316ce791faf2"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_connection.html#a180476e4513ce0ccdc23316ce791faf2">sock::net::TcpConnection::getId</a></div><div class="ttdeci">int getId(void) const </div><div class="ttdoc">获取ID </div><div class="ttdef"><b>Definition:</b> tcp_connection.h:70</div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_connection_html_a9d9ea93c3a51141616167ae78c0238ec"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_connection.html#a9d9ea93c3a51141616167ae78c0238ec">sock::net::TcpConnection::PassTcpConnectionRefFunc</a></div><div class="ttdeci">boost::function&lt; void(TcpConnection &amp;)&gt; PassTcpConnectionRefFunc</div><div class="ttdef"><b>Definition:</b> tcp_connection.h:30</div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_connection_html_ac6a1f1dc74ce847b7aab5f9c1c8d6574"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_connection.html#ac6a1f1dc74ce847b7aab5f9c1c8d6574">sock::net::TcpConnection::State</a></div><div class="ttdeci">State</div><div class="ttdef"><b>Definition:</b> tcp_connection.h:34</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.10
</small></address>
</body>
</html>
